package org.example.com.controller;

import org.example.com.pojo.Reservations;
import org.example.com.pojo.Result;
import org.example.com.pojo.vo.ReservationsVO;
import org.example.com.service.ReservationsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/auth/house")
public class ReservationsController {
    @Autowired
    private ReservationsService reservationsService;
    @PostMapping("/reservation")
    public Result submit(@RequestBody Reservations reservations){
        int id = reservationsService.submit(reservations);
        return Result.success(id);
    }

    @GetMapping("/history")
    public Result history(){
        List<ReservationsVO> reservationsVOList= reservationsService.history();
        return Result.success(reservationsVOList);
    }

    @DeleteMapping("/reservation")
    public Result delete(int id){
        reservationsService.delete(id);
        return Result.success();
    }
}
